package GUI;

import Market.GenCo;
import Market.ACEWEMmodel;
import sim.display.Console;
import sim.display.Controller;
import sim.display.GUIState;
import sim.engine.SimState;
import sim.engine.Steppable;
import sim.portrayal.Inspector;


/**
 * 
 * @author 
 *
 */
public class ACEWEMGUI extends GUIState 
{
	
	private ACEWEMmodel market;

	/**
	 * 
	 * @param state
	 */
	public ACEWEMGUI(SimState state) 
	{
		super(state);
		market=(ACEWEMmodel)state;		
	}

	/**
     * this is the first method that is executed once the start button is pressed
     */
	public void start() 
	{
		super.start();
	}
	
  /**
  * 	
  */
  public void makeGenCoLearn()
  {
	final Steppable updater = new Steppable()
	{	
		public void step(SimState simState) 
		{
			market.makeGenCoLearn();			
		}
		
	};
	this.scheduleImmediatelyAfter(updater);
   }
  
  /** this gives the 'model' tab in the consol of the GUI */
  public Object getSimulationInspectedObject()
  {
  	return state;
  }
  

  public void finish()
  {
  	super.finish();
  }
  
  /**
   * Since the GUIState needs to know when the GUI has been lanched
   * the init method is used to register the visualisations
   * using the c.registerFrame function
   * */
   
  public void init (Controller c)
  {
  	super.init(c);
  	//add more here
  }
  
  public static String getName() 
  { 
	  return "ACEWEM for Wholesale Electricity Markets"; 
  }

  public void quit() 
	{
		super.quit();
		System.exit(0);
	}
  
  public Inspector getInspector()
	{
		Inspector i = super.getInspector(); 
		i.setVolatile(true); 
		return i; 
	}
  
    //To load 'serializable' states - Fix it!
	public void load(SimState state) 
	{
		super.load(state);		
	}
  public static Object getInfo()
	{
		return
		"<H1> <CENTER>  The ACEWEM Project</CENTER></H2>"+
		"<CENTER>Agent-based Computational Economics of the Wholesale Electricity Market</CENTER>";

	}

	/**
	 * 
	 * @param args
	*/
	public static void main(String[] args)
	{	 
	 ACEWEMmodel market = new ACEWEMmodel(System.currentTimeMillis());       
	 ACEWEMGUI gui =new ACEWEMGUI(market);
	 Console c = new Console(gui);
	 c.setBounds(600, 5,500, 300);
	 c.setVisible(true);
     market.finish();
	}

}
